<?php

namespace km\graphics;

interface RasterImageBackend {
	/**
	 * @param string $filename
	 * @return void
	 */
	function loadFile($filename);
	/**
	 * @return int
	 */
	function getWidth();
	/**
	 * @return int
	 */
	function getHeight();
	/**
	 * reset image to a solid background
	 * @param int $width
	 * @param int $height
	 * @param int $r
	 * @param int $g
	 * @param int $b
	 * @param int $alpha
	 * @return void
	 */
	function reset($width, $height, $r = 255, $g = 255, $b = 255, $alpha = 0);
	/**
	 * Reduce image to the specified region, optionally scaling that region to [$new_width x $new_height]
	 * @param int $x
	 * @param int $y
	 * @param int $width
	 * @param int $height
	 * @param int $new_width
	 * @param int $new_height
	 * @return void
	 */
	function region($x, $y, $width, $height, $new_width = null, $new_height = null);
	/**
	 * Paste another image into this one
	 * @param mixed $image valid argument types are determined by the concrete backend
	 * @param int $x
	 * @param int $y
	 * @return void
	 */
	function paste($image, $x = 0, $y = 0);
	/**
	 * Save transformation result to a file
	 * @param string $filename
	 * @return void
	 */
	function saveFile($filename);
	/**
	 * Save transformation result to a string
	 * @param string $filename
	 * @return string
	 */
	function saveString($type);
}